import { IDEFormRawItem } from '@ibiz/model-core';
import { useNamespace } from '@ibiz-template/vue3-util';
import { defineComponent, PropType } from 'vue';
import { FormRawItemController } from './form-rawitem.controller';
import './form-rawitem.scss';

export const FormRawItem = defineComponent({
  name: 'IBizFormRawItem',
  props: {
    modelData: {
      type: Object as PropType<IDEFormRawItem>,
      required: true,
    },
    controller: {
      type: FormRawItemController,
      required: true,
    },
  },
  setup() {
    const ns = useNamespace('form-raw-item');
    return { ns };
  },
  render() {
    if (!this.controller.state.visible) {
      return null;
    }
    return (
      <iBizRawItem
        class={[this.ns.b(), ...this.controller.containerClass]}
        rawItem={this.modelData}
      ></iBizRawItem>
    );
  },
});

export default FormRawItem;
